package com.ruoyi.web.service.impl;

import java.util.List;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.mapper.OldDrugSpecificationMapper;
import com.ruoyi.web.domain.OldDrugSpecification;
import com.ruoyi.web.service.IOldDrugSpecificationService;
import com.ruoyi.common.core.text.Convert;

/**
 * 旧药品规格Service业务层处理
 * 
 * @author drx
 * @date 2024-03-01
 */
@Service
public class OldDrugSpecificationServiceImpl implements IOldDrugSpecificationService 
{
    @Autowired
    private OldDrugSpecificationMapper oldDrugSpecificationMapper;

    /**
     * 查询旧药品规格
     * 
     * @param id 旧药品规格主键
     * @return 旧药品规格
     */
    @Override
    public OldDrugSpecification selectOldDrugSpecificationById(Long id)
    {
        return oldDrugSpecificationMapper.selectOldDrugSpecificationById(id);
    }

    /**
     * 查询旧药品规格列表
     * 
     * @param oldDrugSpecification 旧药品规格
     * @return 旧药品规格
     */
    @Override
    public List<OldDrugSpecification> selectOldDrugSpecificationList(OldDrugSpecification oldDrugSpecification)
    {
        return oldDrugSpecificationMapper.selectOldDrugSpecificationList(oldDrugSpecification);
    }

    /**
     * 新增旧药品规格
     * 
     * @param oldDrugSpecification 旧药品规格
     * @return 结果
     */
    @Override
    public int insertOldDrugSpecification(OldDrugSpecification oldDrugSpecification)
    {
        oldDrugSpecification.setCreateTime(DateUtils.getNowDate());
        oldDrugSpecification.setCreateBy(ShiroUtils.getSysUser().getLoginName());
        return oldDrugSpecificationMapper.insertOldDrugSpecification(oldDrugSpecification);
    }

    /**
     * 修改旧药品规格
     * 
     * @param oldDrugSpecification 旧药品规格
     * @return 结果
     */
    @Override
    public int updateOldDrugSpecification(OldDrugSpecification oldDrugSpecification)
    {
        oldDrugSpecification.setUpdateTime(DateUtils.getNowDate());
        oldDrugSpecification.setUpdateBy(ShiroUtils.getSysUser().getLoginName());
        return oldDrugSpecificationMapper.updateOldDrugSpecification(oldDrugSpecification);
    }

    /**
     * 批量删除旧药品规格
     * 
     * @param ids 需要删除的旧药品规格主键
     * @return 结果
     */
    @Override
    public int deleteOldDrugSpecificationByIds(String ids)
    {
        return oldDrugSpecificationMapper.deleteOldDrugSpecificationByIds(Convert.toStrArray(ids),ShiroUtils.getSysUser().getLoginName());
    }

    /**
     * 删除旧药品规格信息
     * 
     * @param id 旧药品规格主键
     * @return 结果
     */
    @Override
    public int deleteOldDrugSpecificationById(Long id)
    {
        return oldDrugSpecificationMapper.deleteOldDrugSpecificationById(id,ShiroUtils.getSysUser().getLoginName());
    }
}
